//多态
class Demo4_Animal 
{
	public static void main(String[] args) 
	{
		method(new Cat());
		method(new Dog());
	}
	public static void method(Animal a){
		if(a instanceof Cat){
			Cat c = (Cat)a;
			c.eat();
			c.catchMouse();
		} else if(a instanceof Dog){
			Dog c = (Dog)a;
			c.eat();
			c.lookHome();
		} else {
			a.eat();
		}
	}
}

class Animal
{
	public void eat(){
		System.out.println("动物吃饭");
	}
}
class Cat extends Animal
{
	public void eat(){
		System.out.println("猫吃鱼");
	}

	public void catchMouse(){
		System.out.println("抓老鼠");
	}
}
class Dog extends Animal
{
	public void eat(){
		System.out.println("狗吃肉");
	}
	public void lookHome(){
		System.out.println("看家");	
	}
}